<?php
session_start();
require_once 'header.php';
function __autoload($className)
	{
    	require_once('class/' . $className . '.class.php');
	}
session::need_member();
if(!empty($_POST))
{
	$ArrPost=$_POST;
	$Subject=$ArrPost['subject'];
	$Soure=$ArrPost['soureask'];
	$SoureToCheck=$Subject.$Soure;
	$Check=verify::check($SoureToCheck);
	if($Check==0)
	{
		$date=date("Y-m-d");
		$Subject=strval($Subject);
		$Soure=strval($Soure);
		$UserId=session::getuserid();
		$GetTicketId=database::LimitQuery('tickets',array(
		'select' => 'max(ticketid)',
		'condition' => array(
		)
		));
		$TicketInsert=$GetTicketId[0]['max(ticketid)']+1;
		$InsertTicket=database::Insert('tickets', array(
		'userid' => $UserId,
		'ticketid' => $TicketInsert,
		'userpost' => $UserId,
		'subject' => $Subject,
		'contents' => $Soure,
		'replyid' => 1
		));
		$_SESSION["erro"]="Thank You, Our Staff Will check your ticket and reply you as soon as we can !";
		redirect::location("viewtickets.php");
	}
	else 
	{
		$_SESSION["erro"]="Your Input has some problem, plz do not use special character as:"." ? (  ~ ) ! = ";
		redirect::location("login.php");
	}
	
}
else
{
	require_once 'html/ticket.php';
}

?>